var t = require("../../utils/api.js"), a = getApp();

Page({
    data: {
        optionList: [ {
            name: "全部",
            status: "back_money"
        }, {
            name: "处理中",
            status: "50"
        }, {
            name: "已退款",
            status: "70"
        }, {
            name: "已拒绝",
            status: "60"
        } ],
        containerHeight: 0,
        scrollTop: 0,
        currentTab: "back_money",
        curCode: 0,
        data: [],
        loading: !1,
        page: 2,
        showLoding: !0
    },
    onLoad: function(e) {
        var n = wx.getSystemInfoSync(), o = this, r = 0;
        if (o.setData({
            showLoding: !o.data.showLoding
        }), "" != e.id && void 0 != e.id) {
            var i = e.id;
            50 == i ? r = 1 : 70 == i ? r = 2 : 60 == i && (r = 3);
        }
        wx.setNavigationBarColor({
            frontColor: wx.getStorageSync("basic").topcolor,
            backgroundColor: wx.getStorageSync("basic").topbg
        }), this.setData({
            currentTab: "back_money",
            containerHeight: n.windowHeight - Math.round(n.windowWidth / 375 * 55),
            curCode: r
        }), t.getBackMoneyOrder({
            openid: a.globalData.openid,
            status: "back_money"
        }).then(function(t) {
            0 == t.errno && o.setData({
                data: t.data
            }), o.setData({
                showLoding: !o.data.showLoding
            });
        });
    },
    switchNav: function(t) {
        var a = this;
        a.setData({
            data: [],
            showLoding: !a.data.showLoding
        });
        for (var e, n = t.currentTarget.dataset.current, o = a.data.optionList, r = 0; r < o.length; r++) n == o[r].status && (e = r);
        a.setData({
            currentTab: n,
            curCode: e,
            showLoding: !a.data.showLoding
        });
    },
    bindChange: function(e) {
        var n, o = this, r = e.detail.current, i = o.data.optionList;
        o.setData({
            showLoding: !o.data.showLoding
        });
        for (var d = 0; d < i.length; d++) r == d && (n = i[d].status);
        return o.setData({
            currentTab: n
        }), t.getBackMoneyOrder({
            openid: a.globalData.openid,
            status: n
        }).then(function(t) {
            0 == t.errno && o.setData({
                data: t.data
            }), o.setData({
                showLoding: !o.data.showLoding
            });
        }), !1;
    },
    getCurrentList: function(e) {
        var n = this;
        n.setData({
            loading: !0,
            tip: ""
        }), console.log(1), t.getBackMoneyOrder({
            openid: a.globalData.openid,
            status: n.data.currentTab,
            page: n.data.page
        }).then(function(t) {
            var a = n.data.page + parseInt(1), e = n.data.data.concat(t.data);
            0 == t.errno ? n.setData({
                data: e,
                page: a
            }) : wx.showToast({
                title: "已显示全部订单",
                icon: "loading",
                duration: 1e3
            }), n.setData({
                loading: !1
            });
        });
    },
    goOrderDetail: function(t) {
        var a = t.currentTarget.dataset.id, e = t.currentTarget.dataset.orderid;
        wx.navigateTo({
            url: "../refund/refundDetail?id=" + a + "&oid=" + e
        });
    },
    cancelApplication: function(t) {
        t.detail;
        wx.showModal({
            title: "撤销申请",
            content: "您确定要撤销本次退款申请吗？",
            success: function(t) {
                wx.showToast({
                    title: "撤销成功",
                    icon: "none"
                });
            }
        });
    },
    btndetail: function(t) {
        var a = t.currentTarget.dataset.id, e = t.currentTarget.dataset.orderid;
        wx.navigateTo({
            url: "../refund/refundDetail?id=" + a + "&oid=" + e
        });
    },
    applyAgin: function(t) {
        var a = t.currentTarget.dataset.id, e = t.currentTarget.dataset.gid, n = t.currentTarget.dataset.ossid;
        wx.navigateTo({
            url: "../refund/refundApply?id=" + a + "&gid=" + e + "&ossid=" + n
        });
    }
});